<template>
  <div>
    <BasicTable @register="registerTable" :searchInfo="searchInfo"> </BasicTable>
  </div>
</template>
<script lang="ts" setup name="UserGoodsCheckRecordIndex">
import { BasicTable } from '@apps/antd-admin/src/components/Table';
import { useDrawer } from '@apps/antd-admin/src/components/drawer';
import { useBaseTable } from '@apps/antd-admin/src/hooks';

import { columns, searchFormSchema } from '../data/checkRecordData';
import { Api } from '../data/checkRecordApi';
import { useMessage } from '@apps/antd-admin/src/hooks/web/useMessage';
import { reactive } from 'vue';

const [registerDrawer, { openDrawer }] = useDrawer();
const { prefixCls, tableContext, handleDelete, handleSuccess, handlePost, handleBatchDelete } = useBaseTable({
  designScope: 'UserGoodsCheckRecordIndex-template',
  tableProps: {
    //表格标题
    title: '核销记录',
    //主键字段
    rowKey: 'checkrecordId',
    //列表接口
    listUrl: Api.page,
    handlerName: 'busAdminCheckRecordListHandler',
    //删除接口
    delUrl: Api.remove,
    //列定义
    columns,
    //查询表单配置
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    showActionColumn: false,
    //查询前处理
    beforeFetch: params => {
      params.useAirportIds = '';
      params.airportIds = '';
      let useAirportIdArray: any = params.useAirportIdArray;
      console.info('--------------beforeFetch-------useAirportIdArray--------------------------', useAirportIdArray);
      if (useAirportIdArray) {
        params.useAirportIds = useAirportIdArray.join(',');
      }
      delete params.useAirportIdArray;
      let airportIdArray: any = params.airportIdArray;
      console.info('--------------beforeFetch-------airportIdArray--------------------------', airportIdArray);
      if (airportIdArray) {
        params.airportIds = airportIdArray.join(',');
      }
      delete params.airportIdArray;
      let employeeIdArray: any = params.employeeIdArray;
      console.info('--------------beforeFetch-------employeeIdArray--------------------------', employeeIdArray);
      if (employeeIdArray) {
        params.employeeIds = employeeIdArray.join(',');
      }
      delete params.employeeIdArray;
      return params;
    },
  },
});

const [registerTable, { reload }, { rowSelection, hasSelectedRows }] = tableContext;
const { createMessage, createConfirm } = useMessage();

const searchInfo = reactive<Recordable>({});

function setSearchInfoProps(userGoodsId) {
  console.info('userGoodsId', userGoodsId);
  searchInfo.userGoodsId = userGoodsId;
}

defineExpose({
  setSearchInfoProps,
});
</script>
